<!-- eslint-disable vue/multi-word-component-names -->
<template>
    <div class="container">
        <h1>For Work</h1>
        <div class="input-container">
            <input type="text" v-model="newTodo" @keyup.enter="addTodo" placeholder="添加文本" />
            <button @click="addTodo">+</button>
        </div>
        <TodoList :todos="todos" @delete-todo="deleteTodo" />
    </div>
</template>

<script>
import TodoList from '@/components/TodoList.vue';

export default {
    components: {
        TodoList
    },
    data() {
        return {
            newTodo: '',
            todos: []
        };
    },
    methods: {
        addTodo() {
            if (this.newTodo.trim() !== '') {
                this.todos.push({
                    text: this.newTodo,
                    completed: false
                });
                this.newTodo = '';
            }
        },
        deleteTodo(index) {
            this.todos.splice(index, 1);
        }
    }
};
</script>

<style scoped>
.container {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 24px;
    color: #333;
}

.input-container {
    margin-bottom: 20px;
}

input[type="text"] {
    width: calc(100% - 70px);
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
}

button {
    width: 70px;
    padding: 10px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

button:hover {
    background-color: #0056b3;
}

.TodoList {
    margin-top: 20px;
}
</style>
